using System;
#pragma warning disable 3002
namespace TSharp.Core.Util
{
    /// <summary>
    /// 	<para>2010/9/27</para>
    /// 	<para>TANGJINGBO</para>
    /// 	<author>tangjingbo</author>
    /// </summary>
    partial class SafeConvert
    {
        /// <summary>
        /// Toes the boolean.
        /// </summary>
        /// <param name="array">The array.</param>
        /// <returns></returns>
        public static bool[] ToBooleanArray(this string[] array)
        {
            if (array == null)
                return null;
            if (array.Length == 0)
                return new bool[0];
            return Array.ConvertAll(array, ToBoolean);
        }

        /// <summary>
        /// Toes the double.
        /// </summary>
        /// <param name="array">The array.</param>
        /// <returns></returns>
        public static double[] ToDoubleArray(this string[] array)
        {
            if (array == null)
                return null;
            if (array.Length == 0)
                return new double[0];
            return Array.ConvertAll(array, ToDouble);
        }

        /// <summary>
        /// Toes the single.
        /// </summary>
        /// <param name="array">The array.</param>
        /// <returns></returns>
        public static float[] ToSingleArray(this string[] array)
        {
            if (array == null)
                return null;
            if (array.Length == 0)
                return new float[0];
            return Array.ConvertAll(array, ToSingle);
        }

        /// <summary>
        /// Toes the decimal.
        /// </summary>
        /// <param name="array">The array.</param>
        /// <returns></returns>
        public static decimal[] ToDecimalArray(this string[] array)
        {
            if (array == null)
                return null;
            if (array.Length == 0)
                return new decimal[0];
            return Array.ConvertAll(array, ToDecimal);
        }

        /// <summary>
        /// Toes the byte.
        /// </summary>
        /// <param name="array">The array.</param>
        /// <returns></returns>
        public static byte[] ToByteArray(this string[] array)
        {
            if (array == null)
                return null;
            if (array.Length == 0)
                return new byte[0];
            return Array.ConvertAll(array, ToByte);
        }

        /// <summary>
        /// Toes the S byte.
        /// </summary>
        /// <param name="array">The array.</param>
        /// <returns></returns>
        public static sbyte[] ToSByteArray(this string[] array)
        {
            if (array == null)
                return null;
            if (array.Length == 0)
                return new sbyte[0];
            return Array.ConvertAll(array, ToSByte);
        }

        /// <summary>
        /// Toes the int16.
        /// </summary>
        /// <param name="array">The array.</param>
        /// <returns></returns>
        public static short[] ToInt16Array(this string[] array)
        {
            if (array == null)
                return null;
            if (array.Length == 0)
                return new short[0];
            return Array.ConvertAll(array, ToInt16);
        }

        /// <summary>
        /// Toes the U int16.
        /// </summary>
        /// <param name="array">The array.</param>
        /// <returns></returns>
        public static ushort[] ToUInt16Array(this string[] array)
        {
            if (array == null)
                return null;
            if (array.Length == 0)
                return new ushort[0];
            return Array.ConvertAll(array, ToUInt16);
        }

        /// <summary>
        /// Toes the int32.
        /// </summary>
        /// <param name="array">The array.</param>
        /// <returns></returns>
        public static int[] ToInt32Array(this string[] array)
        {
            if (array == null)
                return null;
            if (array.Length == 0)
                return new int[0];
            return Array.ConvertAll(array, ToInt32);
        }

        /// <summary>
        /// Toes the U int32.
        /// </summary>
        /// <param name="array">The array.</param>
        /// <returns></returns>
        public static uint[] ToUInt32Array(this string[] array)
        {
            if (array == null)
                return null;
            if (array.Length == 0)
                return new uint[0];
            return Array.ConvertAll(array, ToUInt32);
        }

        /// <summary>
        /// Toes the int64.
        /// </summary>
        /// <param name="array">The array.</param>
        /// <returns></returns>
        public static long[] ToInt64Array(this string[] array)
        {
            if (array == null)
                return null;
            if (array.Length == 0)
                return new long[0];
            return Array.ConvertAll(array, ToInt64);
        }

        /// <summary>
        /// Toes the U int64.
        /// </summary>
        /// <param name="array">The array.</param>
        /// <returns></returns>
        public static ulong[] ToUInt64Array(this string[] array)
        {
            if (array == null)
                return null;
            if (array.Length == 0)
                return new ulong[0];
            return Array.ConvertAll(array, ToUInt64);
        }

        /// <summary>
        /// Toes the date time.
        /// </summary>
        /// <param name="array">The array.</param>
        /// <returns></returns>
        public static DateTime[] ToDateTimeArray(this string[] array)
        {
            if (array == null)
                return null;
            if (array.Length == 0)
                return new DateTime[0];
            return Array.ConvertAll(array, ToDateTime);
        }

        /// <summary>
        /// Toes the time span.
        /// </summary>
        /// <param name="array">The array.</param>
        /// <returns></returns>
        public static TimeSpan[] ToTimeSpanArray(this string[] array)
        {
            if (array == null)
                return null;
            if (array.Length == 0)
                return new TimeSpan[0];
            return Array.ConvertAll(array, ToTimeSpan);
        }

        /// <summary>
        /// Toes the char.
        /// </summary>
        /// <param name="array">The array.</param>
        /// <returns></returns>
        public static char[] ToCharArray(this string[] array)
        {
            if (array == null)
                return null;
            if (array.Length == 0)
                return new char[0];
            return Array.ConvertAll(array, ToChar);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="array"></param>
        /// <returns></returns>
        public static string[] ToStringArray(this object[] array)
        {
            if (array == null)
                return null;
            if (array.Length == 0)
                return new string[0];
            return Array.ConvertAll(array, ToStringObject);
        }

        /// <summary>
        /// Toes the enum.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="array">The array.</param>
        /// <returns></returns>
        public static T[] ToEnumArray<T>(this string[] array) where T : struct
        {
            if (array == null)
                return null;
            if (array.Length == 0)
                return new T[0];
            return Array.ConvertAll(array, ToEnum<string, T>);
        }
    }
}